<template>
  <div class="B">
    <h1>我是B</h1>
  </div>
</template>

<script setup lang="ts">
import { onMounted } from 'vue'
import emitter from '../../utils/mitt';

const onFun = (data:string)=>{
  console.log(data);
}

emitter.on('on-mittA', onFun)

emitter.on('*',(eventName: string, data: string)=>{
  console.log(eventName, data);
})

onMounted(() => {
  emitter.off('on-mittA', onFun)
  emitter.all.clear()
})

</script>

<style>
.B {
  width: 200px;
  height: 200px;
  color: rgb(171, 32, 76);
  background-color: chartreuse;
}
</style>